﻿using System;
using NHibernate;
using NHibernate_1;

namespace Tutorial_CMD
{
	class Program
	{
		static void Main()
		{
			Domain.Init();

			ISession session = Domain.CurrentSession;
			ITransaction tr = session.BeginTransaction();

			Book book = new Book("NW8523IDISDN", "How to learn not to do stupid things v.5");

			session.Save(book);
			long bookId = book.ID;
			
			tr.Commit();
			session.Flush();

			Book book1 = session.Get<Book>(bookId);

			Console.WriteLine(book1.ISBN + " " + book1.Title);

			if (book == book1) { Console.WriteLine("Yep!!!"); }

			Domain.Close();
			Console.ReadKey();
		}
	}
}
